import datetime
import os
import sys
import time

from selenium import webdriver
from selenium.webdriver.edge.service import Service
from webdriver_manager.microsoft import EdgeChromiumDriverManager


class Driver:
    driver=""
    def __init__(self):
        #打开edge驱动管理
        EdsIns=EdgeChromiumDriverManager().install()
        options=webdriver.EdgeOptions()
        #创建edge浏览器对象
        self.driver=webdriver.Edge(service=Service(EdsIns),options=options)

        # 截屏功能

    def getScreenShot(self):
        dirname = datetime.datetime.now().strftime('%Y-%m-%d')
        if not os.path.exists("../images/" + dirname):
            os.mkdir("../images/" + dirname)
        filename = sys._getframe().f_back.f_code.co_name + "-" + datetime.datetime.now().strftime('%Y-%m-%d-%H%M%S') + ".png"
        self.driver.save_screenshot(f'../images/{dirname}/' + filename)
Lunta=Driver()

